package uia.alumni.web;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;



/**
 * Log out the user.
 * 
 * @author Even Åby Larsen (even.larsen@uia.no)
 */
public class Logout extends Command {
    public static final String SERVLET_NAME = "logout";


    public Logout() {
        super(null);
    }


    /**
     * Log out the user.  This implementation is rather crude.
     * It erases the user data from the session.
     *
     * @param request DOCUMENT ME!!
     * @throws IOException DOCUMENT WHEN!!
     */
    public void execute(HttpServletRequest request,
            HttpServletResponse response) throws ServletException, IOException {
        HttpSession session = request.getSession(true);
        // just to make sure
        session.setAttribute(USER, null);
        forwardTo(HOME, request, response);
    }


    public final static long serialVersionUID = 1;
}
